# -*- coding: utf-8 -*-
import scrapy
from CSDNSpider import items as iClass


class MySpider(scrapy.Spider):
    name = 'MySpiders'
    start_urls = ['https://blog.csdn.net/longji/article/category/6840109',
                  'https://blog.csdn.net/longji/article/category/6840109/2',
                  'https://blog.csdn.net/longji/article/category/6840109/3',
                  'https://blog.csdn.net/longji/article/category/6840109/4']
    items = []
    def title_parse(self, response):
        pass

    def parse(self, response):
        # print(type(response))
        items = []
        for box in response.xpath('//span[@class="link_title"]'):
            item = iClass.CsdnspiderItem()
            item['link'] = box.xpath('.//@href').extract()[0]
            item['title'] = box.xpath('.//text()').extract()[1]
            items.append(item)
            # return item
        # print(len(items))
        # for item in items:
            # print(item)
        # for box in response:
        #     print(box)
        return items

    pass
